﻿using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using WJSHWebApi.DBModel;
using WJSHWebApi.InterFace;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WJSHWebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FJFL : ControllerBase
    {
        IDBInterface iDBInterface;
        public FJFL(IDBInterface dBInterface)
        {
            iDBInterface = dBInterface;
        }
        // GET: api/<ZJFL>
        [HttpGet]
        public IEnumerable<FJFLTLD_Cache_Entity> GetFJFLCacheslist()
        {

            return iDBInterface.Where<FJFLTLD_Cache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == true);
        }


        [HttpGet]
        public FJFLTLD_Cache_Entity GetFJFLTLCache_EntityByRemark(string Remark)
        {

            return iDBInterface.FirstOrDefault<FJFLTLD_Cache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.Remark == Remark);
        }


        [HttpGet]
        public FJFLTLD_Entity GetFJFLTL_EntityByRemark(string Remark)
        {

            return iDBInterface.FirstOrDefault<FJFLTLD_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.Remark == Remark);
        }
        [HttpGet]
        public IEnumerable<FJFLTLD_Entity> GetFJFLlist()
        {

            return iDBInterface.Where<FJFLTLD_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == false);
        }

        [HttpGet]
        public IEnumerable<FJFLTLD_Cache_Entity> GetFJFLCacheslistEmpty()
        {

            return iDBInterface.Where<FJFLTLD_Cache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == false);
        }
        [HttpGet]
        public IEnumerable<FJFLTLD_Entity> GetFJFLlistEmpty()
        {

            return iDBInterface.Where<FJFLTLD_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.IsHave == true);
        }
        [HttpGet]
        public FJFLCache_Entity GetFJFLCache_EntityByRemark(string Remark)
        {

            return iDBInterface.FirstOrDefault<FJFLCache_Entity>(X => X.IsEnable == true && X.IsCreat == false && X.Remark == Remark);
        }

        [HttpGet]
        public bool UpdataNoHave(string Remark)
        {
            var FJFLCache_Entity = iDBInterface.FirstOrDefault<FJFLCache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            FJFLCache_Entity.IsHave = false;
            return iDBInterface.Update(FJFLCache_Entity);
        }
        [HttpGet]
        public bool UpdataHave(string Remark)
        {
            var FJFLCache_Entity = iDBInterface.FirstOrDefault<FJFLCache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            FJFLCache_Entity.IsHave = true;
            return iDBInterface.Update(FJFLCache_Entity);
        }


        [HttpGet]
        public bool UpdataNoHaveFJFLTLDCache(string Remark)
        {
            var FJFLTLD_Cache_Entity = iDBInterface.FirstOrDefault<FJFLTLD_Cache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            FJFLTLD_Cache_Entity.IsHave = false;
            return iDBInterface.Update(FJFLTLD_Cache_Entity);
        }
        [HttpGet]
        public bool UpdataHaveFJFLTLDCache(string Remark)
        {
            var FJFLTLD_Cache_Entity = iDBInterface.FirstOrDefault<FJFLTLD_Cache_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            FJFLTLD_Cache_Entity.IsHave = true;
            return iDBInterface.Update(FJFLTLD_Cache_Entity);
        }
        [HttpGet]
        public bool UpdataNoHaveFJFLTLD(string Remark)
        {
            var FJFLTLD_Entity = iDBInterface.FirstOrDefault<FJFLTLD_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            FJFLTLD_Entity.IsHave = false;
            return iDBInterface.Update(FJFLTLD_Entity);
        }
        [HttpGet]
        public bool UpdataHaveFJFLTLD(string Remark)
        {
            var FJFLTLD_Entity = iDBInterface.FirstOrDefault<FJFLTLD_Entity>(x => x.IsEnable == true && x.IsCreat == false && x.Remark == Remark);
            FJFLTLD_Entity.IsHave = true;
            return iDBInterface.Update(FJFLTLD_Entity);
        }

    }
}

